package com.weilx959.spt.app.controller;

import com.weilx959.spt.core.component.FormItemControl;
import com.weilx959.spt.core.config.Config;
import com.weilx959.spt.core.config.FormControlConfig;
import javafx.fxml.FXML;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

@Slf4j
public class TestFormControlController {
    @FXML
    public FormControlConfig formControlConfig;

    @FXML
    public void initialize() {
        log.info("Test Controller init! control size : {} ", formControlConfig.getControls().size());

        Optional.ofNullable(formControlConfig)
            .map(FormControlConfig::getControls)
            .ifPresent(controls -> controls.forEach(FormItemControl::submit));
    }

    public Config getConfig() {
        return formControlConfig;
    }
}
